package com.itheima.app.exception;

import com.itheima.domain.vo.ErrorResult;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.ControllerAdvice;
import org.springframework.web.bind.annotation.ExceptionHandler;

@ControllerAdvice
public class GlobalExceptionAdvice {


    // 处理并捕获异常
    @ExceptionHandler(Exception.class)
    public ResponseEntity chuliyichang(Exception ex){
        // 1.将异常信息写入到日志中。。。
        ex.printStackTrace();

        // 2.客户端友情提示
        return ResponseEntity.status(500).body(ErrorResult.error());
    }
}
